package util;

import java.util.ArrayList;

import dk.isten.andro.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CostumBaseAdapterStilling extends BaseAdapter {
	private static ArrayList<Item> searchArrayList;
	
	private LayoutInflater mInflater;

	public CostumBaseAdapterStilling(Context context, ArrayList<Item> items) {
		searchArrayList = items;
		mInflater = LayoutInflater.from(context);
		
	}

	public int getCount() {
		return searchArrayList.size();
	}

	public Object getItem(int position) {
		return searchArrayList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.listeelement_stilling, null);
			holder = new ViewHolder();
			holder.txtPlace = (TextView) convertView.findViewById(R.id.listeelem_place);
			holder.txtNavn = (TextView) convertView.findViewById(R.id.listeelem_hold1);
			holder.txtKampe = (TextView) convertView.findViewById(R.id.listeelem_kampe);
			holder.txtPoint = (TextView) convertView.findViewById(R.id.listeelem_point);
			holder.txtVat = (TextView) convertView.findViewById(R.id.listeelem_vat);
			holder.txtMaal = (TextView) convertView.findViewById(R.id.listeelem_maal);
			
			
			
						
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.txtPlace.setText(searchArrayList.get(position).getPlacering());
		holder.txtNavn.setText(searchArrayList.get(position).getName());
		holder.txtKampe.setText(searchArrayList.get(position).getKampe());
		holder.txtPoint.setText(searchArrayList.get(position).getPoint());
		holder.txtVat.setText(searchArrayList.get(position).getVat());
		holder.txtMaal.setText(searchArrayList.get(position).getMaal());
		


		
		return convertView;
	}

	static class ViewHolder {
		TextView txtNavn;
		TextView txtKampe;
		TextView txtPoint;
		TextView txtVat;
		TextView txtMaal;
		TextView txtPlace;
	}
}
